﻿@model Kooboo.CMS.Sites.Models.Page
@{
    var customTabs = Kooboo.CMS.Sites.Extension.UI.Tabs.CustomTabs.GetTabs(ViewContext.RequestContext).ToArray(); // Kooboo.CMS.Web.Areas.Sites.PageCustomTabs.Tabs(Model.Layout).ToArray();
}
<div class="tabs">
    <ul class="tab-index clearfix">
        <li class="active">
            <a href="#basicInfo">
                @("Designer".Localize())
            </a>@Html.IconImage("arrow blue-down")
        </li>
        <li>
            <a href="#setting">
                @("Settings".Localize())
            </a>@Html.IconImage("arrow blue-down")
        </li>
        <li>
            <a href="#navigation">
                @("Navigation".Localize())
            </a>@Html.IconImage("arrow blue-down")
        </li>
        <li>
            <a href="#htmlmeta">
                @("HTML meta".Localize())
            </a>@Html.IconImage("arrow blue-down")
        </li>

        <li>
            <a href="#route">
                @("URL route".Localize())
            </a>@Html.IconImage("arrow blue-down")
        </li>
        <li>
            <a href="#outputCache">
                @("Output cache".Localize())
            </a>@Html.IconImage("arrow blue-down")
        </li>
        <li>
            <a href="#plugins">
                @("Plug-ins".Localize())
            </a>@Html.IconImage("arrow blue-down")
        </li>
        @if (!string.IsNullOrEmpty(Kooboo.CMS.Sites.Models.Site.Current.Repository))
        {
            <li>
                <a href="#datarules">
                    @("DataRules".Localize())
                </a>@Html.IconImage("arrow blue-down")
            </li>
        }
        @if (!string.IsNullOrEmpty(Kooboo.CMS.Sites.Models.Site.Current.Membership))
        {
            <li>
                <a href="#permission">
                    @("Permission".Localize())
                </a>@Html.IconImage("arrow blue-down")
            </li>
        }
        @if (customTabs.Length == 0)
        {
            <li>
                <a href="#customFields">
                    @("Custom fields".Localize())
                </a>@Html.IconImage("arrow blue-down")
            </li>
        }
        @foreach (var tab in customTabs)
        {
            <li>
                <a href="#@tab.Name">
                    @Html.Raw(tab.DisplayText.Localize())
                </a>@Html.IconImage("arrow blue-down")
            </li>
        }
    </ul>
    <div class="tab-content active" id="basicInfo">
        @Html.Partial("PageDesign", (bool?)(ViewBag.IsCreating))
    </div>
    <div class="tab-content" id="setting">
        <table>
            @Html.EditorFor(m => m.Layout, new { HtmlAttributes = new { @class = "medium" } })
            @Html.EditorFor(m => m.ContentTitle, new { HtmlAttributes = new { @class = "medium" } })
            @if (Request["fullName"] == null)
            {
                @Html.EditorFor(m => m.IsDefault)
            }
            @Html.EditorFor(m => m.EnableTheming)
            @Html.EditorFor(m => m.EnableScript)
            @Html.EditorFor(m => m.PageType)
            @Html.EditorFor(m => m.Searchable)
            @Html.EditorFor(m => m.RequireHttps)
        </table>
    </div>
    <div class="tab-content" id="navigation">
        @Html.EditorFor(m => m.Navigation)
    </div>
    <div class="tab-content" id="htmlmeta">
        @Html.EditorFor(m => m.HtmlMeta)
    </div>

    <div class="tab-content" id="route">
        @Html.EditorFor(m => m.Route)
    </div>
    <div class="tab-content" id="outputCache">
        @Html.Partial("_OutputCache", Model)
    </div>
    <div class="tab-content" id="plugins">
        @Html.EditorFor(o => o.Plugins)
    </div>
    @if (!string.IsNullOrEmpty(Kooboo.CMS.Sites.Models.Site.Current.Repository))
    {
        <div class="tab-content" id="datarules">
            @Html.EditorFor(m => m.DataRules)
        </div>
    }
    @if (!string.IsNullOrEmpty(Kooboo.CMS.Sites.Models.Site.Current.Membership))
    {
        <div class="tab-content" id="permission">
            @Html.EditorFor(m => m.Permission)
        </div>
    }

    @if (customTabs.Length == 0)
    {
        <div class="tab-content" id="customFields">
            <table>
                <tbody>
                    @Html.EditorFor(m => m.CustomFields)
                </tbody>
            </table>
        </div>
    }
    @foreach (var tab in customTabs)
    {
        <div class="tab-content " id="@tab.Name">
            @Html.Partial(tab.VirtualPath, Model.CustomFields, new ViewDataDictionary())
        </div>
    }
</div>
<script type="text/javascript">
    window.keepLoading = true;
    @if (Model.Published!=true)
    {
        <text>
    $(function () {
        $('#save_bar').click(function (e) {
            var $self = $(this);
            if ($('#IsDefault').is(":checked")) {
                $self.data("confirm", '@("You have set this page as homepage, but it is not yet published! Are you sure?".Localize())');
            }
            else {
                $self.removeData("confirm");
            }
        });
    });
    </text>
    }
</script>
